Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor getReadTheDocsConfig to use Promise #286

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

humitos
Copy link
Member

@humitos humitos commented Apr 9, 2024

Follow Anthony's suggestion from
#64 (comment)

@humitos humitos changed the title Refactor getReadTheDocsConfig to use `Promise Refactor getReadTheDocsConfig to use Promise Apr 9, 2024
@humitos humitos marked this pull request as ready for review April 10, 2024 09:58
@humitos humitos requested a review from a team as a code owner April 10, 2024 09:58
@humitos humitos requested a review from agjohnson April 10, 2024 09:58
src/readthedocs-config.js Outdated Show resolved Hide resolved
src/readthedocs-config.js Outdated Show resolved Hide resolved
src/readthedocs-config.js Outdated Show resolved Hide resolved
src/readthedocs-config.js Outdated Show resolved Hide resolved
I found a pattern that I like 👍🏼 . I think it's a clear way to
communicate users what's going on, but also leaves the door open to
expand checks/validations in the future. I also imagine we could even
want to know "What projects are subscribing to the custom event?" in
case we need to contact them due to a breaking change or similar.

## Examples

#### Calling `event.detail.initialize()` without having defined the
`<meta ... />` HTML tag:


![Screenshot_2024-04-09_13-57-20](https://github.com/readthedocs/addons/assets/244656/b1757a08-aa44-4c3b-a5c2-8dbe73a477b4)

#### Calling `event.detail.data()` without calling `.initialize()`
first:


![Screenshot_2024-04-09_13-56-01](https://github.com/readthedocs/addons/assets/244656/476a934b-7668-4a58-8dbc-8e4254f6049c)


Closes #279
@humitos
Copy link
Member Author

humitos commented Apr 11, 2024

OK. I re-structured how we are calling the Promises and I think it's a lot easier to follow and understand now. Can you please do a final review here and let me know if this is fine? After that, I will merge this PR into the one's its based, and finish the small bits there in case there are any.

@humitos humitos requested a review from agjohnson April 11, 2024 14:55
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, the logic matches what I would expect 👍

@@ -64,73 +67,80 @@ function _getApiUrl(sendUrlParam) {
return url;
}

function getReadTheDocsUserConfig(sendUrlParam) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking this out is a good idea 👍 Often, splitting up nested async/promises makes the code easier to follow

@humitos humitos merged commit 98768a4 into humitos/custom-event Apr 15, 2024
2 of 4 checks passed
@humitos humitos deleted the humitos/custom-event-promise branch April 15, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants